# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=exrex
pkgname=('python2-exrex' 'exrex')
_pkgname=exrex
pkgver=149.b91c075
pkgrel=2
pkgdesc='Irregular methods on regular expressions.'
groups=('blackarch' 'blackarch-misc')
arch=('any')
url='https://github.com/asciimoo/exrex'
license=('AGPL3')
makedepends=('git' 'python2-setuptools' 'python-setuptools' 'python2-pip'
             'python-pip' 'python2-wheel' 'python-wheel')
source=("git+https://github.com/asciimoo/$_pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $_pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd "$_pkgname"

  sed -i '1 i # -*- coding: UTF-8 -*-' setup.py

  cd $srcdir

  cp -a "$_pkgname"{,-2}
}

build() {
  cd "$_pkgname-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname"

  python setup.py build
}

package_python2-exrex() {
  depends=('python2')

  cd "$_pkgname-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  mv "$pkgdir/usr/bin/$_pkgname"{,2}
  rm "$pkgdir/usr/bin/$_pkgname.py"
}

package_exrex() {
  depends=('python')

  cd "$_pkgname"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  rm "$pkgdir/usr/bin/$_pkgname.py"

  install -Dm 644 README.md "$pkgdir/usr/share/doc/$_pkgname/README.md"
}

